Type.registerNamespace("SharpPieces");
Type.registerNamespace("SharpPieces.Web.JQuery");

SharpPieces.Web.JQuery.BlockUI = function(element) {
    SharpPieces.Web.JQuery.BlockUI.initializeBase(this, [element]);
}

SharpPieces.Web.JQuery.BlockUI.prototype = {
    initialize: function() {
        SharpPieces.Web.JQuery.BlockUI.callBaseMethod(this, 'initialize');

        //add our init function
        Sys.Application.add_init(Function.createDelegate(this, this.initControl));
    },

    initControl: function() {

    },

    block: function(element, timeout) {
        var me = this;
        if (element)
            $(element).block({ message: $(me.get_ContentElementID()) });
        else
            $.blockUI({ message: $(me.get_ContentElementID()) });

        if (timeout)
            setTimeout(function() { me.unblock(element); }, timeout);
    },
    unblock: function(element) {
        var me = this;
        if (element)
            $(element).unblock();
        else
            $.unblockUI();
    },

    get_ContentElementID: function() {
        return this._contentElementID;
    },
    set_ContentElementID: function(contentElementID) {
        this._contentElementID = contentElementID;
    }
}

SharpPieces.Web.JQuery.BlockUI.registerClass('SharpPieces.Web.JQuery.BlockUI', Sys.UI.Control);
